package com.aoxin.controller.course.systemCourse;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.aoxin.model.dto.ThemeCourseDto;
import com.aoxin.service.inter.course.systemCourse.ThemeCourseService;
import com.aoxin.util.AjaxRes;
import com.aoxin.util.Const;
import com.aoxin.util.enumerate.OperateType;
import com.aoxin.util.log.LogInfo;
/**
 * 主题课
 * @author lop
 *
 */
@RestController
@RequestMapping("/web/system/")
public class ThemeCourseController {
	@Autowired
	ThemeCourseService  themeCourseService;
	
	/**
	 * 添加主题课程	
	 * @param res
	 * @param schoolCourseIds
	 * @return
	 */
	@RequestMapping("insertThemeCourse")
	@LogInfo(operateType = OperateType.INSERT, content = "添加主题课程")
	public AjaxRes insertThemeCourse(AjaxRes res,@RequestParam("schoolCourseIds")Integer schoolCourseIds[]){
		try {
			this.themeCourseService.insertThemeCourse(schoolCourseIds);  
			res.setSucceedMsg(Const.SAVE_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
	
	/**
	 * 删除主题课程
	 * @param res
	 * @param themeCourseId
	 * @return
	 */
	@RequestMapping("deleteThemeCourse")
	@LogInfo(operateType = OperateType.DELETE, content = "删除主题课程")
	public AjaxRes deleteThemeCourse(AjaxRes res,@RequestParam("themeCourseId")List<Integer> themeCourseId){
		try {
			this.themeCourseService.deleteThemeCourse(themeCourseId);  
			res.setSucceedMsg(Const.DEL_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
	/**
	 * 查询主题课程
	 * @param res
	 * @param themeCourseDto
	 * @return
	 */
	@RequestMapping("getThemeCourse")
	@LogInfo(operateType = OperateType.QUERY, content = "查询主题课程")
	public AjaxRes getThemeCourse(AjaxRes res,ThemeCourseDto themeCourseDto){
		try {
			List<ThemeCourseDto> themeCourseDtoS=this.themeCourseService.getThemeCourse(themeCourseDto);  
			res.setSucceed(themeCourseDtoS, Const.DATA_SUCCEED);
		} catch (Exception e) {
			res.setFailMsg(e.getMessage());
		}
		return res;
	}
	
	

}
